<template>
  <div class="main-header">
    <div class="menu-icon" @click="handleMenuIconClick">
      <el-icon size="28px">
        <component :is="hasFold ? 'Expand' : 'Fold'" />
      </el-icon>
    </div>
    <div class="content">
      <div class="breadcrumb"><HeaderCrumb /></div>
      <div class="info"><HeaderInfo /></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import HeaderInfo from './subcomponent/header-info.vue'
import HeaderCrumb from './subcomponent/header-crumb.vue'

const emit = defineEmits(['flodChange'])
const hasFold = ref<boolean>(false)
function handleMenuIconClick() {
  hasFold.value = !hasFold.value
  // 发射事件给父组件
  emit('flodChange', hasFold.value)
}
</script>

<style lang="scss" scoped>
.main-header {
  display: flex;
  align-items: center;
  flex: 1;
  height: 100%;
  .menu-icon {
    display: flex;
    align-items: center;
    cursor: pointer;
  }
  .content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    padding: 0 18px;
  }
}
</style>
